/*
 * Licensed to Nanjing RedOrange Co. ltd (RedOrange) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * RedOrange licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package redora.rdo.api;

import redora.rdo.exceptions.WrongType;

/**
 * A set that is delivered in chunks should implement the Paginated interface.
 * When a new result set is queried, the PageType can be set. The PageType will
 * influence the specifics of the pagination behavior:<br>
 * - Page: 'normal' pagination where the user has to press next and previous buttons;<br>
 * - Scroll: automatic pagination where new records are fetch when the user scrolls down the list.
 * <br>
 * A List or Set type that implements Paginated should have implementations for Page and Scroll.
 * 
 * @see Page
 * @see Scroll
 */
public interface Paginated {
	public PageType type();
	/**
	 * This method is not guaranteed because the underlying table can have been changed.
	 * @return True If there are more records to be expected. 
     */
 	public boolean hasMoreRecords();
	/**
	 * Fetches the next page of records.
	 * @return True If new records were found.
	 */
	public boolean next();
	/**
	 * Handle to the Page object.
	 * @return
	 * @throws WrongType When Page is not the current PageType a WrongType exception is thrown.
	 */
	public Page page() throws WrongType;
	/**
	 * Handle to the Scroll object.
	 * @return
	 * @throws WrongType When Scroll is not the current PageType a WrongType exception is thrown.
	 */
	public Scroll scroll() throws WrongType;
}
